package com.yunhe.policyfulfillment.task;

import com.yunhe.common.model.ResultObject;
import com.yunhe.policyfulfillment.policyful.service.PolicyApplyMatterStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName MatterHandleStatisticsTask
 * @Description TODO
 * @Author HeTao
 * @Date 2021/9/18 14:08
 * @Version 1.0
 **/
@Api(value = "MatterHandleStatisticsTask",description = "申请事项处理数量统计分析",tags = "{MatterHandleStatistics_Task}")
@RestController
@RequestMapping(value = "/publishTimed")
@Slf4j
public class MatterHandleStatisticsTask {

    @Autowired
    private PolicyApplyMatterStatisticsService policyApplyMatterStatisticsService;

    @ApiOperation("根据部门按日统计事项申请处理数量")
    @RequestMapping(value ="/matterHandleStatistics",method = RequestMethod.POST)
    @Scheduled(cron = "0 0 2 * * ? ")
    @Async
    public ResultObject matterHandleStatistics() throws InterruptedException {
        log.info("定时发布数据定时任务开始");
        policyApplyMatterStatisticsService.matterHandleStatistics();
        log.info("定时发布数据定时任务结束");
        return new ResultObject<>(null);
    }
}
